<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加教师</title>
    <link type="text/css" rel="stylesheet" href="/layui/css/layui.css">
    <script src="/jquery/jquery-3.6.0.js"></script>
    <script src="/layuimoduls/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
</head>
<body>
<form class="layui-form" lay-filter="form" id="form">
    <div class="layui-form-item">
        <label class="layui-form-label">教师姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="username"  class="layui-input" >
        </div>
        <div class="layui-form-mid layui-word-aux" >账号注册成功，老师姓名无法修改哦</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" id="pwd" name="password" placeholder="请输入密码"  class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password2" placeholder="请再次输入密码"  class="layui-input" id="pwd2">
        </div>
        <div class="layui-form-mid layui-word-aux" id="msg">请填写6到12位密码</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">教师电话</label>
        <div class="layui-input-inline">
            <input type="text" name="serialnumber"  class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">您的邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="mailnumber"  class="layui-input" >
        </div>
        <div class="layui-form-mid layui-word-aux" ></div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-disabled"  lay-submit="" lay-filter="addTeacher" id="send" readonly="readonly">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

</body>
<script>
    layui.use(['form'], function () {
        var form = layui.form;
        $('#form').click(function (e) {
            //禁用表单的默认提交事件
            e.preventDefault();
        })
        form.on('submit(addTeacher)', function (data) {
            layer.alert("确定提交？");
            var arr = [];
            console.log(JSON.stringify(data))
            $.ajax({
                url:'/addTeacher',
                data:JSON.stringify(data),
                type:'post',
                contentType:'application/json;charset=utf-8',
                dataType:'json',
                success:function (response) {
                    if(response.success){
                        layer.msg(response.msg)
                        return false;
                    }else{
                        layer.msg(response.msg)
                        return false;
                    }
                }
            })
        });
    })
</script>
</html>